<?php
 class Utilisateur {
	protected $id_user;
	protected $nom;
	protected $prenom;
	protected $email;
	protected $pass;
	protected $type;
	
	
	public function __construct($id=null,$nom,$prenom,$email,$pass,$type){
		$this->id_user = $id;
		$this->nom = $nom;
		$this->prenom = $prenom;
		$this->email = $email;
		$this->pass = $pass;	
		$this->type = $type;
	}
	
	public function setId_user($id){
		if(is_int($id)){
			$this->id_user = $id;
		} 
	}
	public function getId_user(){
		return $this->id_user;	
	}
	
	public function setNom($nom){
		if(is_string($nom)){
			$this->nom = $nom;
		} 
	}
	public function getNom(){
		return $this->nom;	
	}
	
	public function setPrenom($prenom){
		if(is_string($prenom)){
			$this->prenom = $prenom;
		}
	}
	public function getPrenom(){
		return $this->prenom;	
	}
	public function setEmail($email){
		if(is_string($email))
			$this->email = $email;	
	}
	public function getEmail(){
		return $this->email;	
	}
	
	public function setPass($pass){
		if(is_string($pass))
			$this->pass = $pass;	
	}
	public function getPass(){
		return $this->pass;	
	}
	public function getType(){
		return $this->type;	
	}
public function hydrate(array $donnees)
 {
  foreach ($donnees as $key => $value)
  {
    // On récupère le nom du setter correspondant à l'attribut.
    $method = 'set'.ucfirst($key);
         
    // Si le setter correspondant existe.
    if (method_exists($this, $method))
    {
      // On appelle le setter.
      $this->$method($value);
    }
  }
}
}